feat(toolpath-cli): add path auth command for Pathbase login#52
Merged
eliothedeman merged 2 commits intomainfrom Apr 23, 2026
Merged
feat(toolpath-cli): add path auth command for Pathbase login#52eliothedeman merged 2 commits intomainfrom
path auth command for Pathbase login#52eliothedeman merged 2 commits intomainfrom
Conversation
Adds a new top-level `path auth` subcommand with `login` / `logout` /
`status` / `whoami` that authenticates the CLI against a Pathbase instance
so future `path upload` calls can attach a bearer token.
`path auth login` prints `<base>/auth/cli`, prompts the user to visit the
URL in a browser, sign in, and paste the 8-character code. The CLI posts
the code to `/api/v1/auth/cli/redeem` to trade it for a session token,
then writes `{url, token, user}` to `~/.toolpath/credentials.json`
(file 0600, parent dir 0700 on Unix). All authenticated calls use
`Authorization: Bearer <token>`.
- Server URL resolves from `--url`, then `$PATHBASE_URL`, then the
`https://pathbase.dev` default.
- `$TOOLPATH_CONFIG_DIR` overrides the credentials directory.
- Storage helpers take a `&Path` so they are unit-testable without a real
`$HOME`; 6 unit tests cover disk roundtrip, parent-dir creation, 0600
mode, and empty/missing files. Integration tests cover `auth --help`
and a login against an unreachable URL.
Requires the matching Pathbase PR (CLI grant endpoints + Bearer auth
extractor) to be live on the target server.
The wasm build target compiles out `reqwest::blocking`, so the new `cmd_auth` module (which relies on a blocking HTTP client and a local credentials file) can't link for `wasm32-unknown-emscripten`. The CLI `auth` command doesn't make sense in a browser context anyway — there's no persistent filesystem or HOME — so the cleanest fix is to hide it from the wasm build entirely. - Move `reqwest` under `[target.'cfg(not(target_os = "emscripten"))']`. - Gate `mod cmd_auth`, the `Commands::Auth` enum variant, and its dispatch arm behind `#[cfg(not(target_os = "emscripten"))]`.
|
🔍 Preview deployed: https://9ed2423d.toolpath.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Configuration
Test plan
Requires
Companion server change: empathic/pathbase#4 (CLI grant endpoints + Bearer auth extractor)